package cn.ren.hai.base.service.impl;

import cn.ren.hai.base.db.DbMapper;
import cn.ren.hai.base.entity.RhViewTable;
import cn.ren.hai.base.entity.RhViewTableField;
import cn.ren.hai.base.service.BaseService;
import cn.ren.hai.base.service.RhViewTableFieldService;
import cn.ren.hai.base.service.RhViewTableService;
import cn.ren.hai.core.entity.BaseData;
import cn.ren.hai.core.filter.QueryFilter;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: 王道
 * @Date: 2022/1/24 21:45
 * @Description:
 */
@Service
public class BaseServiceImpl implements BaseService {

    private final DbMapper dbMapper;

    private final RhViewTableService rhViewTableService;

    private final RhViewTableFieldService rhViewTableFieldService;

    public BaseServiceImpl(DbMapper dbMapper, RhViewTableService rhViewTableService, RhViewTableFieldService rhViewTableFieldService) {
        this.dbMapper = dbMapper;
        this.rhViewTableService = rhViewTableService;
        this.rhViewTableFieldService = rhViewTableFieldService;
    }
    /**
     * 查询列表集合
     * @param viewTableId 视图列表id
     * @param queryFilters 过滤条件
     * @return
     */
    @Override
    public List<BaseData<Object>> list(Long viewTableId, List<QueryFilter> queryFilters) {

        RhViewTable viewTable = rhViewTableService.getById(viewTableId);
        StringBuffer sql = new StringBuffer();
        List<RhViewTableField> list = rhViewTableFieldService.lambdaQuery().eq(RhViewTableField::getTableId, viewTable.getId())
                .list();
        list.forEach(x->
                        sql.append(x.getName()+",")
                );
        return null;
    }
}
